programming4us
           
 
 
SQL Server

Configuring SQL Server 2008 : Database Mail

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
10/17/2010 5:46:14 PM
Database Mail is a solution that enables you to send email messages from SQL Server. It is disabled by default and uses the SMTP standard to deliver messages, so there is no need to have a MAPI client such as Outlook installed on the server.

It runs as an isolated process outside of SQL Server to ensure it doesn’t affect the availability of your database, it can be configured with multiple SMTP servers for redundancy, and is fully supported to run on a Windows failover cluster.

Database Mail uses SQL Server Service Broker to provide asynchronous message delivery, and you must be a member of the DatabaseMailUserRole in msdb to be able to send email messages. It is not supported in SQL Server Express.

Scenarios where Database Mail is often used include:

  • Sending a basic message on completion of a SQL Server Agent job

  • Executing a query and emailing the results automatically as an attachment

You can also send emails in HTML format.

Configuring Database Mail

Before you configure Database Mail you’ll need to have access to an existing SMTP server. Microsoft IIS, which comes with Windows, has an SMTP service that you can configure easily if you don’t have an existing SMTP server on your network.

The easiest way to configure Database Mail is by using the Configure Database Mail wizard accessible by right-clicking Database Mail under the Management section of a SQL Server that you have connected to in Management Studio.

You also use the same wizard to manage the Database Mail configuration after you’ve initially set up. When you run the wizard for the first time, you’ll need to select Set up Database Mail by performing the following tasks:

Next you’ll need to specify a Profile name and create new SMTP accounts through which to send emails. You can add multiple SMTP accounts on different servers to a Profile. If the first account fails then Database Mail will try the next account and server in the list. In Figure 1 in the active window, you can see a second email account and SMTP server being added to a Database Mail profile (seen in the inactive window).

Figure 1. Adding a Database Mail Account to a Profile


Once you’ve created a profile, the next screen will prompt you to configure profile security, where you can setup your profile to be Public and accessible to all users, or Private and accessible to a specific user.

The last screen allows you to configure parameters such as retry attempts, but generally you can just leave the defaults.

Once you’ve run through the wizard you’ll now be able to use Database Mail by calling the sp_send_dbmail stored procedure. Here is sample code that sends a basic email to an address using the CompanySQLServers profile that was created using the Database Mail wizard:

EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'CompanySQLServers',
@recipients = '[email protected]',
@body = 'Output from procedure X was not as expected',
@subject = 'Procedure X execution';
Other -----------------
- Configuring SQL Server 2008 : Full-Text Indexing
- SQL Server 2008 : Working with Indexes
- SQL Server 2008 : Working with Constraints
- SQL Server 2008 : Working with Tables and Views
- SQL Server 2008 : Viewing and Modifying Data (part 3) - Creating Functions and Creating Triggers
- SQL Server 2008 : Viewing and Modifying Data (part 2) - Creating Stored Procedures
- SQL Server 2008 : Viewing and Modifying Data (part 1) - Creating Views
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us